package com.aabte.spring.beans;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author Daniel
 */
public class Car implements InitializingBean, DisposableBean {

    public Car() {
        System.out.println("Invoke Car constructor...");
    }

    /**
     * 实例化且属性装配后被调用
     */
    public void init() {
        System.out.println("Invoke Car init method...");
    }

    @Override
    public void destroy() {
        System.out.println("Invoke Car destroy method...");
    }

    /**
     * 实例化且属性装配后被调用，优先于{@link #init}方法
     */
    @Override
    public void afterPropertiesSet() {
        System.out.println("Invoke Car afterPropertiesSet method...");
    }

    /**
     * 实例化且属性装配后被调用，优先于{@link #afterPropertiesSet}和{@link #init}方法
     */
    @PostConstruct
    public void postConstruct() {
        System.out.println("Invoke Car postConstruct method...");
    }

    /**
     * Bean对象从容器移除时被调用
     */
    @PreDestroy
    public void preDestroy() {
        System.out.println("Invoke Car preDestroy method...");
    }

}
